import java.util.ArrayList;


public class Min extends Operator {
	public int nArguments;
	private ArrayList aa;
	
	public Min(ArrayList s){
		
		aa=s;
		
		this.setNargument(aa.size()-1);
	}
    /**
     * Return the number of arguments this operator takes
     */
    public int nArguments() {
	return nArguments;
    }
    
    /**
     * Sets the number of arguments this operator takes
     */
    public void setNargument(int i)
    {
    	this.nArguments=i; 
    }

    /**
     * Evaluate this operator on the given expression
     */
    public Data evaluate(Data args[]) throws TypeException {
    	if (!(args[0] instanceof NumberData)) {
    	    throw new TypeException(getClass().getName()
    				+ ": argument is not a number");
    	}
    	
    
    	
    	
    		
    	return new NumberData(calc_min1());
    
    }
    
 protected Double calc_min1()throws TypeException {
	 
	//if ((aa==null)|(aa.size()<1)) throw new TypeException("function max takes 2 or more arguments");
    	
	 

    	
    	Double f = (Double)aa.get(0);
    	for (int i = 0; i<(aa.size()) ; i++ )
    	{	
    		
    		
    		Double b = (Double)aa.get(i);
    		
    		if (b < f ){
    			f = b;
    		}
    		
    	}
    	//java.lang.Math.max(2,3,6,5);
    	
    	return f;
    	
    }

    
    

    /**
     * Return a string representation of this operator
     */
    public String toString() {
	return " ";
    }
}
